home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / bprof-1.1 / bprof-1 / bprof / String.sfpnt.VHMap.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-19  |  2.1 KB  |  85 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /* 
  3. Copyright (C) 1988 Free Software Foundation
  4.     written by Doug Lea (dl@rocky.oswego.edu)
  5.  
  6. This file is part of the GNU C++ Library.  This library is free
  7. software; you can redistribute it and/or modify it under the terms of
  8. the GNU Library General Public License as published by the Free
  9. Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.  This library is distributed in the hope
  11. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  12. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  13. PURPOSE.  See the GNU Library General Public License for more details.
  14. You should have received a copy of the GNU Library General Public
  15. License along with this library; if not, write to the Free Software
  16. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18.  
  19.  
  20. #ifndef _StringsfpntVHMap_h
  21. #ifdef __GNUG__
  22. #pragma interface
  23. #endif
  24. #define _StringsfpntVHMap_h 1
  25.  
  26. #include "String.sfpnt.Map.h"
  27.  
  28.  
  29. class StringsfpntVHMap : public StringsfpntMap
  30. {
  31. protected:
  32.   String*           tab;
  33.   sfpnt*           cont;
  34.   char*          status;
  35.   unsigned int   size;
  36.  
  37. public:
  38.                 StringsfpntVHMap(sfpnt  dflt,unsigned int sz=DEFAULT_INITIAL_CAPACITY);
  39.                 StringsfpntVHMap(StringsfpntVHMap& a);
  40.                 ~StringsfpntVHMap();
  41.  
  42.   sfpnt&          operator [] (String& key);
  43.  
  44.   void          del(String& key);
  45.  
  46.   Pix           first();
  47.   void          next(Pix& i);
  48.   String&          key(Pix i);
  49.   sfpnt&          contents(Pix i);
  50.  
  51.   Pix           seek(String& key);
  52.   int           contains(String& key);
  53.  
  54.   void          clear(); 
  55.   void          resize(unsigned int newsize = 0);
  56.  
  57.   int           OK();
  58. };
  59.  
  60. inline StringsfpntVHMap::~StringsfpntVHMap()
  61. {
  62.   delete [] tab;
  63.   delete [] cont;
  64.   delete [] status;
  65. }
  66.  
  67. inline int StringsfpntVHMap::contains(String& key)
  68. {
  69.   return seek(key) != 0;
  70. }
  71.  
  72. inline String& StringsfpntVHMap::key(Pix i)
  73. {
  74.   if (i == 0) error("null Pix");
  75.   return *((String*)i);
  76. }
  77.  
  78. inline sfpnt& StringsfpntVHMap::contents(Pix i)
  79. {
  80.   if (i == 0) error("null Pix");
  81.   return cont[((unsigned)(i) - (unsigned)(tab)) / sizeof(String)];
  82. }
  83.  
  84. #endif
  85.